package com.qqt.csr.im.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class SensitiveWordResultDTO implements Serializable {
    @Serial
    private static final long serialVersionUID = -588470901104666593L;

    /**
     * 租户id
     */
    private String tenantId;

    /**
     * 显示规则：0 星号加密；1 敏感词高亮
     */
    private Integer showType;

    /**
     * 敏感词列表
     */
    private List<Word> words;

    @Getter
    @Setter
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @ToString
    @Accessors(chain = true)
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Word implements Serializable{

        @Serial
        private static final long serialVersionUID = -2926424502963136778L;

        /**
         * 敏感词
         */
        private String word;

        /**
         * 开始下标
         */
        private int startIndex;

        /**
         * 结束下标
         */
        private int endIndex;

        /**
         * 标签信息
         */
        private List<SensitiveWordTagDTO> tagDTOList;
    }

    public static SensitiveWordResultDTO of(String tenantId, Integer showType, List<Word> words) {
        return SensitiveWordResultDTO.builder()
                .tenantId(tenantId)
                .showType(showType)
                .words(words)
                .build();
    }
}
